package com.example.demo.test;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.example.demo.vo.TestVO;
import com.volcengine.service.vod.IVodService;
import com.volcengine.service.vod.impl.VodServiceImpl;
import com.volcengine.service.vod.model.business.VodAudioStreamMeta;
import com.volcengine.service.vod.model.business.VodGetMediaInfosData;
import com.volcengine.service.vod.model.business.VodMediaInfo;
import com.volcengine.service.vod.model.business.VodSourceInfo;
import com.volcengine.service.vod.model.request.VodGetMediaInfosRequest;
import com.volcengine.service.vod.model.response.VodGetMediaInfosResponse;
import org.apache.commons.codec.binary.Hex;
import org.apache.http.HttpEntity;
import org.apache.http.NameValuePair;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ByteArrayEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;

import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

public class Demo {

    public static void main(String[] args) {
        //查询视频对应音频,抽帧截图地址
        IVodService vodService = VodServiceImpl.getInstance();
        vodService.setAccessKey("AKLTZmEyNzdjZDc0MGVkNDU4MGI5NDAyNjkzM2I0ZDVlNDU");
        vodService.setSecretKey("WVRnM01qRTFNRGxoWW1VM05ERmpOR0ZqWldOaVpESTVOR016TjJJell6Yw==");
        VodGetMediaInfosRequest.Builder req = VodGetMediaInfosRequest.newBuilder();
        req.setVids("v0d269g10002cdlpbn19be205bcm8bfg");
        req.setVids("v0d269g10002cdlpbn99be205bcm8bi0");
        //更新源视频fps,code,Md5,码率(Kbps),图片封面地址信息
        VodGetMediaInfosResponse mediaInfosResp = null;
        try {
            mediaInfosResp = vodService.getMediaInfos(req.build());
        } catch (Exception e) {
            System.out.println(e);
        }
        VodGetMediaInfosData vodGetMediaInfosData = mediaInfosResp.getResult();
        List<VodMediaInfo> mediaInfoList = vodGetMediaInfosData.getMediaInfoListList();
        VodMediaInfo vodMediaInfo = mediaInfoList.get(0);
        VodSourceInfo sourceInfo = vodMediaInfo.getSourceInfo();
        VodAudioStreamMeta audioStreamMeta = sourceInfo.getAudioStreamMeta();
        System.out.println(audioStreamMeta);

    }
}
